package net.qunzhi.modules.cms.controller;

import java.util.Arrays;
import net.qunzhi.common.utils.BaseQuery;
import net.qunzhi.common.annotation.SysLog;
import net.qunzhi.modules.app.query.AlarmRecordQuery;
import net.qunzhi.modules.cms.query.AlarmRecordRecordQuery;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import net.qunzhi.modules.cms.entity.TbAlarmRecordEntity;
import net.qunzhi.modules.cms.service.TbAlarmRecordService;
import net.qunzhi.common.utils.PageUtils;
import net.qunzhi.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


/**
 * 监控报警记录
 *
 * @author zjr
 * @date 2021-11-03 11:50:15
 */
@Api(tags = "监控报警记录相关")
@RestController
@RequestMapping("cms/tbAlarmRecord")
public class TbAlarmRecordController {
    @Autowired
    private TbAlarmRecordService tbAlarmRecordService;

    /**
     * 列表
     */
    @ApiOperation("列表")
    @GetMapping("/list")
    @RequiresPermissions("cms:tbAlarmRecord:list")
    public R list(AlarmRecordRecordQuery query){
        PageUtils page = tbAlarmRecordService.queryPage(query);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("信息")
    @GetMapping("/info/{id}")
    @RequiresPermissions("cms:tbAlarmRecord:info")
    public R info(@PathVariable("id") Integer id){
		TbAlarmRecordEntity tbAlarmRecord = tbAlarmRecordService.getById(id);

        return R.ok().put("tbAlarmRecord", tbAlarmRecord);
    }

    /**
     * 保存
     */
    @ApiOperation("保存")
    @SysLog("监控报警记录保存")
    @PostMapping("/save")
    @RequiresPermissions("cms:tbAlarmRecord:save")
    public R save(@RequestBody TbAlarmRecordEntity tbAlarmRecord){
		tbAlarmRecordService.save(tbAlarmRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("修改")
    @SysLog("监控报警记录修改")
    @PostMapping("/update")
    @RequiresPermissions("cms:tbAlarmRecord:update")
    public R update(@RequestBody TbAlarmRecordEntity tbAlarmRecord){
		tbAlarmRecordService.updateById(tbAlarmRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除")
    @SysLog("监控报警记录删除")
    @PostMapping("/delete")
    @RequiresPermissions("cms:tbAlarmRecord:delete")
    public R delete(@RequestBody Integer[] ids){
		tbAlarmRecordService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
